{-# OPTIONS -Wall #-}

module Perc where

import Lirio.Base.Duration
import Lirio.Base.Overloading
import Lirio.Percussion
import Lirio.DrumPitchNames
import qualified Lirio.DrumPitchNamesShort as D
import Lirio.Score
import Lirio.ScoreDoc

import System.Cmd



main = do 
    writeFile "perc.ly" (renderDoc80 doc)
    system    "lilypond perc.ly"
  where 
    doc    = execScore full_score


full_score :: Score ()
full_score =  do { version "2.12.2"
                 ; newline
                 ; cdef <- chacha_def
                 ; newline
                 ; chacha_score cdef
                 }
 

chacha_score :: Var -> Score ()
chacha_score v = 
    score <+> block ( 
      command "new" <+> text "DrumStaff" <+> block (
        usevar v))  

chacha_def :: Score Var
chacha_def = vardef "chacha" body 
  where
   body = command "drummode" <+> block ( 
              time 4 4 <$> command "stemUp" <$> notelist notelist_chacha)

-- Note - @time@ should be available to notelists...

notelist_chacha :: NoteList ()
notelist_chacha = 
       beam (    chord [ D.hc, D.cymr ] dEighth 
              >> note D.hhp dEighth 
              >> chord [ D.hc, D.cymr ] dEighth 
              >> chord [ D.bd, D.cymr ] dEighth )
    >> beam (    chord [ D.hc, D.cymr ] dEighth 
              >> note D.hhp dEighth 
              >> chord [ D.bd, D.hc, D.cymr ] dEighth 
              >> note D.cymr dEighth )
